function main() {
    const self = this;
    setTimeout(() => {
        let treeEle = self.$$("tree_panel_8u0z0f");
        let departmentId = api.USER_INFO().departmentId || "";
        const params = [{
            name: "unitUuIds",
            valueContent: departmentId
        }];
        // get-senior-domain-unit-id  "ds_mod:43997d3e-eaf4-4d33-b832-26bc911a6187"
        // get-domain-unit-region-type" "ds_mod:627f14ac-5e03-4177-9fad-e1e709671a37"
        // 获取区划层级
        api.DATA_SOURCE_EXECUTE("ds_mod:627f14ac-5e03-4177-9fad-e1e709671a37", "ddcat", params, [], "").then(rs => {
                if (!rs.hasError) {
                    try {
                        const result = rs.result;
                        // 顶级层级
                        let unit_id = null;
                        if (result && (result.type === -1)) {
                            treeEle.params.unitId = unit_id;
                            treeEle.doQuery();
                            // 当前部门
                            window.claimFromUnitId = unitId;
                        } else {
                            // 获取配置项为执法主体或单位
                            api.EXEC_FORMULA("ENTITY_SELECT_ONE('ds_tbl:t_47ac6252fc43469baa839f533f51438d',ITEM_VALUE,QUERY_EQ(name,'LAW_CHECK_SENIOR_DOMAIN_MODE'))").then(res => {
                                if (res === '' || res.result === '0') {
                                    // 获取当前主体的unitPath
                                    api.EXEC_FORMULA("ENTITY_SELECT_ONE('ds_tbl:t_64bdc418261e4d198e57b6a4f95ad42d',unit_path,QUERY_EQ(unit_uuid,'" + departmentId + "'))").then(resPath => {
                                        debugger
                                        let unitPath = resPath.result.slice(0, resPath.result.lastIndexOf('/'))
                                        if(unitPath == '' || unitPath == null){
                                            treeEle.params.unitId = null;
                                            treeEle.doQuery();
                                        }else{
                                            const unitPath = [{
                                                name: "unitPath",
                                                valueContent: unitPath
                                            }];
                                            api.DATA_SOURCE_EXECUTE("ds_api:053c64fa-424c-46c6-b5ec-556b73aab375", "api", unitPath, [], "").then(rs => {
                                                debugger;
                                                if (!rs.hasError) {
                                                    try {
                                                        const result = JSON.parse(rs.result);
                                                        let unitId = -1;
                                                        let flag = 0;
                                                        if (result.result) {
                                                            unitId = result.result.unit_id || "";
                                                            flag = 1
                                                        }
                                                        window.claimFromUnitId = unitId;
                                                        treeEle.params.unitId = unitId;
                                                        treeEle.params.flag = flag;
                                                        treeEle.doQuery();
                                                    } catch (error) {
                                                        console.error('解析结果失败:', error);
                                                    }
                                                } else {
                                                    console.error('API 请求返回错误:', rs.message);
                                                }
                                            });
                                        }
                                    });

                                } else {
                                    // 执法主体
                                    // get-senior-domain-law-subject_id "ds_mod:ec7ce26f-94a4-4ea0-8172-41d5aa2bc372"
                                    api.DATA_SOURCE_EXECUTE("ds_mod:ec7ce26f-94a4-4ea0-8172-41d5aa2bc372", "ddcat", params, [], "").then(rs => {
                                        debugger;
                                        if (!rs.hasError) {
                                            try {
                                                const result = rs.result;
                                                let unitId = -1;
                                                let flag = 0;
                                                if (result) {
                                                    unitId = result.unit_id || "";
                                                    flag = 1
                                                }
                                                treeEle.params.unitId = unitId;
                                                treeEle.params.flag = flag;
                                                treeEle.doQuery();
                                                window.claimFromUnitId = unitId;
                                            } catch (error) {
                                                console.error('解析结果失败:', error);
                                            }
                                        } else {
                                            console.error('API 请求返回错误:', rs.message);
                                        }
                                    });
                                }
                            })
                        }
                    } catch (error) {
                        console.error('解析结果失败:', error);
                    }
                } else {
                    console.error('API 请求返回错误:', rs.message);
                }
            }
        )
    })
}
